package util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import bean.*;



public class HibernateUtil
{
	private static final SessionFactory sessionFactory;
    static
    {
    	try
        {
    		AnnotationConfiguration config = new AnnotationConfiguration();
    		config.addAnnotatedClass(Cliente.class);
    		config.addAnnotatedClass(Cotizacion.class);
    		config.addAnnotatedClass(Factura.class);
    		config.addAnnotatedClass(ItemCotizacion.class);
    		config.addAnnotatedClass(ItemFactura.class);
    		config.addAnnotatedClass(ItemListaPrecios.class);
    		config.addAnnotatedClass(ItemOrdenCompra.class);
    		config.addAnnotatedClass(ItemPedidoVenta.class);
    		config.addAnnotatedClass(ItemRemito.class);
    		config.addAnnotatedClass(ItemSolicitudCompra.class);
    		config.addAnnotatedClass(ListaPrecios.class);
    		config.addAnnotatedClass(OficinaVenta.class);
    		config.addAnnotatedClass(OrdenCompra.class);
    		config.addAnnotatedClass(PedidoVenta.class);
    		config.addAnnotatedClass(Proveedor.class);
    		config.addAnnotatedClass(Remito.class);
    		config.addAnnotatedClass(Rodamiento.class);
    		config.addAnnotatedClass(SolicitudCompra.class);
    		config.addAnnotatedClass(SolicitudCotizacion.class);
    		config.addAnnotatedClass(ItemSolicitudCotizacion.class);
    		config.addAnnotatedClass(CondicionVenta.class);
    			
			sessionFactory = config.buildSessionFactory();
        }
        catch (Throwable ex)
        {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }
 
    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    }
}
